var rootPath = getRootPath();

$(function() {
	var oriState = $("#oriState").val();
	$("#state > option").each(function() {
		if($(this).val() == oriState) {
			$(this).prop("selected","selected");
		}
	});
	
	//'认证状态'下拉框
	$("#state").change(function() {
		var selectedState = $(this).val();
		if(selectedState == 2) {
			$("#validDateDiv").css("display","block");
		} else {
			$("#validDateDiv").css("display","none");
		}
	});

	$("#verifyEditForm").validate({
		rules : {
			state:{
				required:true
			},
			checkResult:{
				required:true
			},
			validDate:{
				number:true,
				maxlength:5,
				min:1,
				max:30000
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$("#verifyEditForm").ajaxSubmit({
				url : rootPath + '/verify/checkVerifyAndSynData',
				type : 'post',
				contentType : 'application/json;charset=UTF-8',
				success : function(data) {
					if(data.returnCode == '0000') {						
						layer.msg(data.returnMessage,{icon:1,time:1000},function() {
//							parent.window.location.href = rootPath + '/verifyPage';
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
							parent.$("#searchVerify").click();
						});
					} else {
						layer.alert(data.returnMessage);
					}
				},
				error: function (jqXHR, textStatus, errorThrown) {
	            	layer.msg('error!',{icon:1,time:1000});
	            }
			});
			return false;
		}
	});
});